import threading

from utils.singleton_base import SingletonBase
from blocking_resource import BlockingResource
from response import TextResponse
from poker.poker_base import PokerBase

class Event():
    pass

class SGSEvent(Event):
    def __init__(self, u_id):
        self.cond = threading.Condition()
        self.requireUser = u_id


class Game(BlockingResource, SingletonBase, threading.Thread):
    #Game status
    PREPARING, READY, STARTED, ENDED = range(4)
    poker = PokerBase()
    eventStack = []
    respStack = []

    def __init__(self):
        threading.Thread.__init__(self)
        self.status = Game.PREPARING

    def _render_GET(self, request):
        return TextResponse('')

    def setUserList(self, users):
        self.users = users

    def setStatus(self, status):
        assert Game.PREPARING <= status <= Game.ENDED
        self.status = status

    def isPreparing(self):
        return self.status == Game.PREPARING
